<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML>
<html>
<head>
<link href="style/bootstrap.css" rel="stylesheet">
<style type="text/css">
#login {
	padding-left: 300px;
}
#body{
width:auto;
}

</style>
</head>

<body>
	<div class="navbar">
		<div class="navbar-inner">
			<div class="container" style="width: auto;">
				<a class="btn btn-navbar" data-target=".nav-collapse"
					data-toggle="collapse"> <span class="icon-bar"></span> <span
					class="icon-bar"></span> <span class="icon-bar"></span> </a> <a
					class="brand" href="#">品竹缘健康生活馆</a>
				<div class="nav-collapse">
					<ul class="nav">
						<li class="active"><a href="#">首页</a>
						</li>
						<li class="active"><a href="#">用户管理</a>
						</li>
					</ul>

					<ul class="nav pull-right">
						<li class="divider-vertical"></li>
						<li><a href="">角色</a>
						</li>
					</ul>
				</div>
			</div>
		</div>
	</div>
	<div id="login">
		<h3>系统登录</h3>
		<form id="loginForm" action="login.jspx?task=login" method="post">
			用户名：<input type="text" id="username" class="text" name="username"
				onblur="findUser()" /> <span id="tishi" style="display:none"></span><br />

			密码：<input type="password" class="text" name="password" /><br /> <input
				id="loginBtn" type="submit" value="登录" />
		</form>
	</div>

</body>

<script type="text/javascript">
	$(function() {

		function createXMLHttpRequest() {
			if (window.ActiveXObject) {
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			} else {
				xmlHttp = new XMLHttpRequest();
			}
		}

		function findUser() {
			createXMLHttpRequest();

			var name = document.getElementById("username").value;

			xmlHttp.open("POST", "ajax.jspx", true);
			xmlHttp.onreadystatechange = callback;

			xmlHttp.setRequestHeader("Content-type",
					"application/x-www-form-urlencoded");
			xmlHttp.send("username=" + name);

			//xmlHttp.open("GET","ajax.jspx?name="+name,true);
			//xmlHttp.send();
		}
		;
		function callback() {

			var result = xmlHttp.responseText;
			if (result == "error") {
				//document.getElementById("tishi").style.display = "inline";
				 document.getElementById("tishi").innerHTML = "用户名错误"; 
			} else if(result=="isOK"){
				document.getElementById("tishi").innerHTML = "用户名存在";
			}else if(result=="isNull"){
				document.getElementById("tishi").innerHTML = "请输入用户名";
			}

		}
	});
</script>
</html>
